<?php
  class Keke_witkey_proposal_class{
        public $_db;
        public $_tablename;
	    public $_dbop;
	    	 public $_p_id;  		 public $_pro_title; 		 public $_pro_type; 		 public $_pro_desc; 		 public $_pro_time; 		 public $_uid; 		 public $_username; 		 public $_op_uid; 		 public $_op_username; 		 public $_op_content; 		 public $_op_time; 		 public $_pro_status; 
	    public $_cache_config = array ('is_cache' => 0, 'time' => 0 );
	    public $_replace=0;  
	    public $_where;      
	     function  keke_witkey_proposal_class(){ 			 $this->_db = new db_factory ( );			 $this->_dbop = $this->_db->create(DBTYPE);			 $this->_tablename = TABLEPRE."witkey_proposal";		 }	    
	    		public function getP_id(){			 return $this->_p_id ;		}		public function getPro_title(){			 return $this->_pro_title ;		}		public function getPro_type(){			 return $this->_pro_type ;		}		public function getPro_desc(){			 return $this->_pro_desc ;		}		public function getPro_time(){			 return $this->_pro_time ;		}		public function getUid(){			 return $this->_uid ;		}		public function getUsername(){			 return $this->_username ;		}		public function getOp_uid(){			 return $this->_op_uid ;		}		public function getOp_username(){			 return $this->_op_username ;		}		public function getOp_content(){			 return $this->_op_content ;		}		public function getOp_time(){			 return $this->_op_time ;		}		public function getPro_status(){			 return $this->_pro_status ;		}		public function getWhere(){			 return $this->_where ;		}		public function getCache_config() {			return $this->_cache_config;		}
	    		public function setP_id($value){ 			 $this->_p_id = $value;		}		public function setPro_title($value){ 			 $this->_pro_title = $value;		}		public function setPro_type($value){ 			 $this->_pro_type = $value;		}		public function setPro_desc($value){ 			 $this->_pro_desc = $value;		}		public function setPro_time($value){ 			 $this->_pro_time = $value;		}		public function setUid($value){ 			 $this->_uid = $value;		}		public function setUsername($value){ 			 $this->_username = $value;		}		public function setOp_uid($value){ 			 $this->_op_uid = $value;		}		public function setOp_username($value){ 			 $this->_op_username = $value;		}		public function setOp_content($value){ 			 $this->_op_content = $value;		}		public function setOp_time($value){ 			 $this->_op_time = $value;		}		public function setPro_status($value){ 			 $this->_pro_status = $value;		}		public function setWhere($value){ 			 $this->_where = $value;		}		public function setCache_config($_cache_config) {			 $this->_cache_config = $_cache_config; 		}
    	   public  function __set($property_name, $value) {
		 		$this->$property_name = $value; 
			}
			public function __get($property_name) { 
				if (isset ( $this->$property_name )) { 
					return $this->$property_name; 
				} else { 
					return null; 
				} 
			}
	    		function create_keke_witkey_proposal(){		 		 $data =  array(); 					if(!is_null($this->_p_id)){ 				 $data['p_id']=$this->_p_id;			}			if(!is_null($this->_pro_title)){ 				 $data['pro_title']=$this->_pro_title;			}			if(!is_null($this->_pro_type)){ 				 $data['pro_type']=$this->_pro_type;			}			if(!is_null($this->_pro_desc)){ 				 $data['pro_desc']=$this->_pro_desc;			}			if(!is_null($this->_pro_time)){ 				 $data['pro_time']=$this->_pro_time;			}			if(!is_null($this->_uid)){ 				 $data['uid']=$this->_uid;			}			if(!is_null($this->_username)){ 				 $data['username']=$this->_username;			}			if(!is_null($this->_op_uid)){ 				 $data['op_uid']=$this->_op_uid;			}			if(!is_null($this->_op_username)){ 				 $data['op_username']=$this->_op_username;			}			if(!is_null($this->_op_content)){ 				 $data['op_content']=$this->_op_content;			}			if(!is_null($this->_op_time)){ 				 $data['op_time']=$this->_op_time;			}			if(!is_null($this->_pro_status)){ 				 $data['pro_status']=$this->_pro_status;			}			 return $this->_p_id = $this->_db->inserttable($this->_tablename,$data,1,$this->_replace); 		 } 
	    		function edit_keke_witkey_proposal(){ 		 		 $data =  array();  					if(!is_null($this->_p_id)){ 				 $data['p_id']=$this->_p_id;			}			if(!is_null($this->_pro_title)){ 				 $data['pro_title']=$this->_pro_title;			}			if(!is_null($this->_pro_type)){ 				 $data['pro_type']=$this->_pro_type;			}			if(!is_null($this->_pro_desc)){ 				 $data['pro_desc']=$this->_pro_desc;			}			if(!is_null($this->_pro_time)){ 				 $data['pro_time']=$this->_pro_time;			}			if(!is_null($this->_uid)){ 				 $data['uid']=$this->_uid;			}			if(!is_null($this->_username)){ 				 $data['username']=$this->_username;			}			if(!is_null($this->_op_uid)){ 				 $data['op_uid']=$this->_op_uid;			}			if(!is_null($this->_op_username)){ 				 $data['op_username']=$this->_op_username;			}			if(!is_null($this->_op_content)){ 				 $data['op_content']=$this->_op_content;			}			if(!is_null($this->_op_time)){ 				 $data['op_time']=$this->_op_time;			}			if(!is_null($this->_pro_status)){ 				 $data['pro_status']=$this->_pro_status;			}			if($this->_where){ 				 return $this->_db->updatetable($this->_tablename,$data,$this->getWhere()); 			 } 			 else{ 				 $where = array('p_id' => $this->_p_id); 				 return $this->_db->updatetable($this->_tablename,$data,$where); 			} 		 } 
	    		function query_keke_witkey_proposal($is_cache=0, $cache_time=0){ 			 if($this->_where){ 				 $sql = "select * from $this->_tablename where ".$this->_where; 			 } 			 else{ 				 $sql = "select * from $this->_tablename"; 			 } 			if ($is_cache) {			 $this->_cache_config ['is_cache'] = $is_cache;			}			if ($cache_time) {			 $this->_cache_config ['time'] = $cache_time;			 }			 if ($this->_cache_config ['is_cache']) {			     if (CACHE_TYPE) {					 $keke_cache = new keke_cache_class ( CACHE_TYPE );					 $id = $this->_tablename . ($this->_where?"_" .substr(md5 ( $this->_where ),0,6):'');						$data = $keke_cache->get ( $id );							if ($data) {								return $data; 							} else { 								$res = $this->_dbop->query ( $sql ); 								$keke_cache->set ( $id, $res,$this->_cache_config['time'] ); 					 			$this->_where = ""; 								return $res; 							} 						} 			 }else{			 	$this->_where = ""; 				return  $this->_dbop->query ( $sql ); 			 }		 } 
	    		function count_keke_witkey_proposal(){ 			 if($this->_where){ 				 $sql = "select count(*) as count from $this->_tablename where ".$this->_where; 			 } 			 else{ 				 $sql = "select count(*) as count from $this->_tablename"; 			 } 			 $this->_where = ""; 			 return $this->_dbop->getCount($sql); 		 } 
	    		function del_keke_witkey_proposal(){ 			 if($this->_where){ 				 $sql = "delete from $this->_tablename where ".$this->_where; 			 } 			 else{ 				 $sql = "delete from $this->_tablename where p_id = $this->_p_id "; 			 } 			 $this->_where = ""; 			 return $this->_dbop->execute($sql); 		 } 
   }
 ?>